package com.cskaoyan.controller;/*
 *  @Author tsuki
 *  @Date 2021/4/14
 *  @Description
 *
 */

import com.cskaoyan.bean.user.WxUserLoginData;
import com.cskaoyan.service.user.UserService;
import com.cskaoyan.vo.BaseRespVo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class WxUserController {
    @Autowired
    UserService userService;

    //缺userId
    // TODO：@RequestMapping("/wx/user/index")
    public BaseRespVo index(){
        Subject subject = SecurityUtils.getSubject();
        WxUserLoginData loginData = (WxUserLoginData) subject.getPrincipal();
        Integer userId = loginData.getId();
        // Integer userId = 1;
        HashMap<String, Object> map = new HashMap<>(1);
        Map<String,Object> order = userService.wxUnNumQuery(userId);
        map.put("order",order);
        return BaseRespVo.ok(map);
    }
}
